﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Vortex.Tools.FormControls {
    public partial class RangeControlSetMinMaxForm : Form {
        
        public RangeControlSetMinMaxForm() {
            InitializeComponent();
        }

        public bool IsCorrectValues {
            get {
                float value = 0.0f;
                return Single.TryParse(MinValueText.Text, out value) && Single.TryParse(MaxValueText.Text, out value);
            }
        }

        public float MinValue {
            get {
                float value = 0.0f;
                Single.TryParse(MinValueText.Text, out value);
                return value;
            }
            set {
                MinValueText.Text = value.ToString();
            }
        }

        public float MaxValue {
            get {
                float value = 0.0f;
                Single.TryParse(MaxValueText.Text, out value);
                return value;
            }
            set {
                MaxValueText.Text = value.ToString();
            }
        }

        private void ValueText_TextChanged(object sender, EventArgs e) {
            OkButton.Enabled = IsCorrectValues;
        }

        private void RangeControlSetMinMaxForm_Shown(object sender, EventArgs e) {
            OkButton.Enabled = IsCorrectValues;
        }
    }
}
